public class Addn implements Runnable{
    private static Object lock = new Object();
    private static int sum = 0;
    private static int num=1;
@Override
    public void run()
    {

        synchronized(lock)
        {
            for(int i = 1;i<= 10;i++,num++)
            {
                sum +=num;
                System.out.println(Thread.currentThread().getName()+"："+num);
            }
        }
    }

    public static int getSum()
    {
        return sum;
    }
}
